#!/bin/bash
if [ $# -lt 1 ]
then
    echo "za malo argumentow"
    exit -1
fi

cp $1 alias.tmp

while read -r LINE
do
	name=`echo $LINE | cut -f1 -d ' '`
	value=`echo $LINE | cut -f2- -d ' '`
	# dump to file after every substitution
	cat alias.tmp | perl -i.bak -pe"s/alias\s+$name=(\".*?\"|\'.*?\')[;\n]?//g" && echo "alias $name=\"$value\"" > alias.tmp
done < values.tmp
# dump after all substitutions
cat alias.tmp
rm alias.tmp
